import QtQuick 2.12
import QtQuick.Window 2.12

Canvas{
    id: root
    // canvas size
    width: 200; height: 200
    // handler to override for drawing
    onPaint: {
        var ctx = getContext("2d") //绘制对象
        // setup the stroke
        ctx.lineWidth = 4
        ctx.strokeStyle = "blue"
        //setup  the  fill
        ctx.fillStyle = "steelblue"
         // begin a new path to draw
        ctx.beginPath()

        ctx.moveTo(50,50)
        ctx.lineTo(150,50)
        ctx.lineTo(150,150)
        ctx.lineTo(50,150)

        ctx.closePath()

        ctx.fill()
        ctx.stroke()
    }

}
